home *** CD-ROM | disk | FTP | other *** search
/ Leonardo the Inventor / Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso / LEOWINMV / DATABASE.DIR / 00099_Script_CastNumber scripts < prev    next >
Text File  |  1996-03-28  |  4KB  |  132 lines

  1. -- --------------------------------------------------------------
  2. -- Handler setUpCastNumbersFields puts the appropriate data
  3. -- into the given fields
  4.  
  5. on setUpCastNumbersFields
  6.   put empty into field "CastNumbers 1"
  7.   set numTopics = the number of lines in field "browserTopics"
  8.   
  9.   repeat with i = 1 to numTopics
  10.     set topic = line i of field "browserTopics"
  11.     
  12.     put topic
  13.     
  14.     put topic & ":" after field "CastNumbers 1"
  15.     
  16.     -- gather text casts
  17.     gatherCasts(topic, "TEXT")
  18.     
  19.     put ":" after field "CastNumbers 1"
  20.     
  21.     -- gather picture casts
  22.     gatherCasts(topic, "PICTURE")
  23.     
  24.     put ":" after field "CastNumbers 1"
  25.     
  26.     -- gather caption casts
  27.     gatherCasts(topic, "CAPTION")
  28.     
  29.     put RETURN after field "CastNumbers 1"
  30.   end repeat
  31. end
  32.  
  33. -- --------------------------------------------------------------
  34. -- Handler gatherCasts adds the casts of the given type for the
  35. -- to the field "CastNumbers 1".
  36.  
  37. on gatherCasts topic, type
  38.   
  39.   set continue = TRUE
  40.   set index = 1
  41.   
  42.   repeat while continue
  43.     put type
  44.     
  45.     set theCast = the number of cast (topic && type & index)
  46.     if (theCast = -1) then
  47.       -- delete the last space
  48.       delete the last char of field "CastNumbers 1"
  49.       -- drop out of the text repeat loop
  50.       set continue = false
  51.     else
  52.       put theCast & " " after field "CastNumbers 1"
  53.       set index = index + 1
  54.     end if
  55.   end repeat -- gathering casts
  56. end
  57.  
  58.  
  59. -- --------------------------------------------------------------
  60. -- Handler initTextCastNumbersList initializes the global variable
  61. -- topicCastData to the fields "CastNumbers 1" and
  62. -- "CastNumbers 2" which contains a list of text cast names
  63. -- and their corresponding cast numbers.
  64.  
  65. on initTextCastNumbersList
  66.   global topicCastData
  67.   
  68.   set topicCastData = field "CastNumbers 1" -- & field "CastNumbers 2"
  69. end
  70.  
  71. -- --------------------------------------------------------------
  72. -- Handler getTextCastNumber returns the cast number of the given
  73. -- page of text of the given topic by performing a binary search
  74. -- on the global variable topicCastData.
  75.  
  76. on getTextCastNumber whichTopic, whichPage
  77.   global topicCastData
  78.   
  79.   set the itemDelimiter = ":"
  80.   set theLine = binSearchFirstItemInLine (topicCastData, whichTopic, ":")
  81.   
  82.   if (theLine = 0) then
  83.     set the itemDelimiter = ","
  84.     return -1
  85.   end if
  86.   
  87.   set textCastNum = integer(word whichPage of item 2 of line theLine of topicCastData)
  88.   set the itemDelimiter = ","
  89.   return textCastNum
  90. end
  91.  
  92. -- --------------------------------------------------------------
  93. -- Handler getPictureCastNumber returns the cast number of the given
  94. -- picture of the given topic by performing a binary search
  95. -- on the global variable topicCastData.
  96.  
  97. on getPictureCastNumber whichTopic, whichPicture
  98.   global topicCastData
  99.   
  100.   set the itemDelimiter = ":"
  101.   set theLine = binSearchFirstItemInLine (topicCastData, whichTopic, ":")
  102.   
  103.   if (theLine = 0) then
  104.     set the itemDelimiter = ","
  105.     return -1
  106.   end if
  107.   
  108.   set pictureCastNum = integer(word whichPicture of item 3 of line theLine of topicCastData)
  109.   set the itemDelimiter = ","
  110.   return pictureCastNum
  111. end
  112.  
  113. -- --------------------------------------------------------------
  114. -- Handler getCaptionCastNumber returns the cast number of the given
  115. -- caption of the given topic by performing a binary search
  116. -- on the global variable topicCastData.
  117.  
  118. on getCaptionCastNumber whichTopic, whichCaption
  119.   global topicCastData
  120.   
  121.   set the itemDelimiter = ":"
  122.   set theLine = binSearchFirstItemInLine (topicCastData, whichTopic, ":")
  123.   
  124.   if (theLine = 0) then
  125.     set the itemDelimiter = ","
  126.     return -1
  127.   end if
  128.   
  129.   set captionCastNum = integer(word whichCaption of item 4 of line theLine of topicCastData)
  130.   set the itemDelimiter = ","
  131.   return captionCastNum
  132. end